Skip to content

Add Xendit driver - #32

Merged
elbanbydev merged 1 commit into
mainfrom
feature/gateway-xendit
Dec 4, 2026
Merged

elbanbydev merged 1 commit into
mainfrom
feature/gateway-xendit

Conversation

@elbanbydev

Copy link
Copy Markdown
Owner

What this adds

Tahseel::gateway('xendit') - South-East Asia (Indonesia, the Philippines, Malaysia, Thailand, Vietnam, Singapore), on Payment Sessions in PAYMENT_LINK mode. Xendit's own docs point new integrations at Payment Sessions and list the older Invoice API under "migrate to Payment Session", so that is what the driver builds on.

  • createPayment() - POST /sessions with Basic auth (secret key as the username, empty password, as documented) and the api-version header. Returns payment_link_url as the checkout url. Amounts are the currency's smallest unit.
  • verifyAndParseWebhook() - no HMAC exists for this flow. Xendit echoes your dashboard token in x-callback-token, and its docs say comparing it is how you know an event came from them. The driver compares in constant time, refuses a missing or wrong token, reads only payment_session.completed and payment_session.expired, and re-checks a completed event against the session's own status so a session that is not COMPLETED comes through pending. Statuses outside COMPLETED/ACTIVE/EXPIRED/CANCELED are refused.
  • refund() - POST /refunds keyed by Xendit's payment_id (the session webhook carries it), amount required, reason mapped to the documented enum (REQUESTED_BY_CUSTOMER unless you pass a documented code). SUCCEEDED/PENDING/FAILED mapped; a pending refund settles by its own webhook.

Honesty notes

  • No fetch-on-callback: Xendit's documented authentication for this flow is the callback token, not an HMAC plus a read. The driver compensates by refusing any status it cannot map, and the README says plainly that there is no second look.
  • No payment-session cancel wrapper.
  • Fixture-tested only, no live Xendit account has run it - README EN, Arabic README and CHANGELOG all say so.

Metadata

README (EN) + docs/ar/README.md in sync (count 21 → 22, driver table, refund table, full ## Xendit section), CHANGELOG [Unreleased], composer.json description + keywords (xendit, indonesia, idr, southeast asia), config block + XENDIT_* env vars, every optional extra off by default.

Tests

16 fixture tests. Suite 593 passed / 1421 assertions, PHPStan level 8 clean, Pint clean.

Xendit covers Indonesia, the Philippines, Malaysia, Thailand, Vietnam and
Singapore, on Payment Sessions in PAYMENT_LINK mode - the product Xendit's
docs point new integrations at, with the legacy Invoice API listed under
'migrate to Payment Session':

- createPayment() creates a session and returns the hosted payment link.
- Webhooks carry no HMAC: the dashboard's token comes back in
  x-callback-token and is compared in constant time. Only the documented
  session events are read, and a completed event is re-checked against the
  session's own status, so an unpaid session never comes through as paid.
- Refunds are keyed by Xendit's payment_id, with the amount required and the
  documented reason enum, and a pending refund settles by its own webhook.
@elbanbydev
elbanbydev merged commit ac871d8 into main Dec 4, 2026
8 checks passed
@elbanbydev
elbanbydev deleted the feature/gateway-xendit branch December 4, 2026 03:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants